import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'
const RefreshTokenKey = 'Refresh-Token'

const ExpiresInKey = 'Admin-Expires-In'

export function getToken() {
  return localStorage.getItem(TokenKey)
}
export function setRefreshToken(token) {
  return localStorage.setItem(RefreshTokenKey, token)
}
export function getRefreshToken() {
  return localStorage.getItem(RefreshTokenKey)
}
export function setToken(token) {
  return localStorage.setItem(TokenKey, token)
}

export function removeToken() {
  return localStorage.removeItem(TokenKey)
}

export function getExpiresIn() {
  return localStorage.getItem(ExpiresInKey) ?? ''
}
export function removeSession() {
  localStorage.removeItem(TokenKey)
  localStorage.removeItem(RefreshTokenKey)
  localStorage.removeItem(ExpiresInKey)
  Cookies.remove('SMAUTHSESSIONID')
  Cookies.remove('SESSION')
  Cookies.remove('Publish-SESSIONID')
}
export function setExpiresIn(time) {
  return localStorage.setItem(ExpiresInKey, time)
}

export function removeExpiresIn() {
  return localStorage.removeItem(ExpiresInKey)
}
